package cn.sytton.taffecloud.serivce.auth.controller;

import cn.sytton.taffecloud.common.base.doc.*;
import cn.sytton.taffecloud.serivce.auth.util.PwdUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 密码工具控制层
 *
 * @author skyrock
 */
@Api(tags = "密码")
@RestController
@RequestMapping("/pwd")
public class PwdController {

    @ApiOperation("获取加密密码")
    @ApiImplicitParam(name = "pwd", value = "未加密密码", paramType = ParamType.query)
    @GetMapping("/encode")
    public String encode(String pwd) {
        return PwdUtil.encode(pwd);
    }

    @ApiOperation("匹配密码")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "rawPwd", value = "未加密密码", paramType = ParamType.query),
        @ApiImplicitParam(name = "encodePwd", value = "加密密码", paramType = ParamType.query)
    })
    @GetMapping("/matches")
    public Boolean matches(String rawPwd, String encodePwd) {
        return PwdUtil.matches(rawPwd, encodePwd);
    }
}
